<template>
  <section>
    <!-- <search-box>
      <div class="search-input">
        <el-input placeholder="输入客户名称或者用户名称查询" v-model="search_text">
          <template #append>
            <el-button icon="el-icon-search"></el-button>
          </template>
        </el-input>
      </div>
    </search-box> -->
    
    <el-table :data="user_list" border stripe>
      <el-table-column prop="customer_id" label="客户ID"></el-table-column>
      <el-table-column prop="customer_name" label="客户名称"></el-table-column>
      <el-table-column label="用户名称">
        <template #default="scope">
          <div v-for="(item) in scope.row.user_id" :key="item">{{item}}</div>
        </template>
      </el-table-column>
      <el-table-column label="客户eci权限">
        <template #default="scope">
         {{scope.row.eci ? '开通' : '未开通'}}
        </template>
      </el-table-column>
      <el-table-column label="镜像仓库权限">
        <template #default="scope">
          {{scope.row.container_registry ? '开通' : '未开通'}}
        </template>
      </el-table-column>
      <el-table-column label="告警权限">
        <template #default="scope">
          {{scope.row.alarm ? '开通' : '未开通'}}
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template #default="scope">
          <el-button 
            type="text" 
            @click="FnToDash(scope.row)" 
            :disabled="FnBtnDisabled('dashboard')">资源概览</el-button>
        </template>
      </el-table-column>
    </el-table>
  </section>
</template>

<script>
// import searchBox from '../../components/search-box.vue'
import Service from '@/service/customer'
import {authBtnDisabled} from '@/utils/auth.js'
export default {
  // components: { searchBox },
  data() {
    return {
      search_text: "",
      user_list: []
    }
  },
  methods: {
    FnToDash(row) {
      this.$router.push({name: "dashboard", params: {id: row.customer_id}})
    },
    FnGetList() {
      let reqData = {
        token: this.$store.getToken()
      }
      Service.get_customer_list(reqData).then(resData => {
        if(resData.code == "Success") {
          this.user_list = resData.data
        }
      })
    },
    FnBtnDisabled(key) {
      return authBtnDisabled(key, this.$route.meta.name)
    }
  },
  created() {
    this.FnGetList()
  }
}
</script>